FROM ccapnljh.mirror.aliyuncs.com/library/centos

ENV TZ Asia/Shanghai

RUN yum install -y wget gcc make pcre-devel zlib-devel openssl openssl-devel unzip patch

COPY nginx-1.14.0.tar.gz /nginx-1.14.0.tar.gz
RUN tar -xzvf nginx-1.14.0.tar.gz 
WORKDIR nginx-1.14.0
RUN wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master 
RUN unzip master
RUN patch -p0 < ./nginx_upstream_check_module-master/check_1.11.5+.patch
RUN ./configure --prefix=/usr/local/nginx --with-pcre --with-http_ssl_module --add-module=./nginx_upstream_check_module-master
RUN make 
RUN make install 
	
RUN cp /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

RUN mkdir -p /log/nginx/
RUN touch /log/nginx/lmm.access.log /log/nginx/lmm.error.log

# http_stub_status_module Nginx服务状态
# http_limit_req_module 限制来自单个IP地址的请求处理频率。实现的原理是使用漏桶原理。
# stream_limit_conn_module 基于令牌桶算法，可以方便的控制令牌速率，自定义调节限流，就能很好的限制请求数量

#RUN wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master 
#RUN unzip master

#ENV CONFIG --with-http_stub_status_module \
#           --with-http_limit_req_module \
#		   --with-stream_limit_conn_module \
#		   --add-module=/nginx_upstream_check_module-master


ADD  nginx.conf      /usr/local/nginx/conf/nginx.conf
ADD  conf.d/*    /usr/local/nginx/conf/conf.d/

CMD ["nginx", "-g", "daemon off;"]
